package mapper.AlumniManagement;

import entity.Alumni;
import entity.AlumniComment;
import org.apache.ibatis.annotations.*;

import java.util.LinkedHashMap;
import java.util.List;

@Mapper
public interface AlumniMapper {

//    @Update("update User set icon=#{icon},password=#{password} where userId=#{userId}")
//    public int updateUserIcon(String icon,String userId);

    //显示所有校友会中的特定校友会评论
    @Select("select AlumniComment.*,User.name,User.icon from AlumniComment,User where AlumniId=#{AlumniId} and AlumniComment.commentUserId = User.userId")
    public List<LinkedHashMap<String,Object>> selectAlumniComment(@Param("AlumniId") int AlumniId);

    @Select("SELECT Alumni.* ,User.name AS publisherName from UserInfForStu,Alumni,User WHERE UserInfForStu.phoneNumber = #{phoneNumber} AND User.userId = UserInfForStu.phoneNumber AND UserInfForStu.school = Alumni.address AND Alumni.date >=(select now() as Systemtime)")
    public List<LinkedHashMap<String,Object>> showAlumni(@Param("phoneNumber") String phoneNumber);

    @Select("SELECT Alumni.* ,User.name AS publisherName from Alumni,User WHERE Alumni.AlumniId = #{AlumniId} AND Alumni.userId = User.userId")
    public LinkedHashMap<String,Object> showOne_alumni(@Param("AlumniId") String AlumniId);

    @Insert("insert into Alumni(name1,describe1,time,address,userId,date) values(#{name1},#{describe1},#{time},#{address},#{userId},#{date})")
    public int addAlumni(Alumni alumni);

    @Insert("insert into AlumniComment(AlumniId,comment,commentTime,commentUserId) values(#{alumniId},#{comment},#{commentTime},#{commentUserId})")
    public int addAlumniComment(AlumniComment alumniComment);

//    @Select("select User.*,AlumniComment.comment where userId=commentUserId and AlumniId=#{AlumniId}")
//    public List<LinkedHashMap<String,Object>> show_alumniComment(@Param("AlumniId") int AlumniId);

//
//    @Update("update User set userInformationId = #{userInformationId} where userId = #{userId};")
//    public int addUserInformationId(@Param("userInformationId") String userInformationId, @Param("userId") String userId);
}
